<!DOCTYPE html>
<html>

<head>
	<meta charset="utf-8" />
	<meta name="viewport" content="initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
	<meta name="HandheldFriendly" content="true" />
	<meta name="MobileOptimized" content="320" />
	<title>Hello H5+</title>
	<!--<script type="text/javascript" src="../js/mui.min.js"></script>-->
	<script type="text/javascript" src="./../../js/mui.min.js"></script>
	<!--<script type="text/javascript" src="./common.js" ></script>-->
	<script type="text/javascript" src="./../../js/jquery-2.1.0.js"></script>
	<script type="text/javascript" src="./../../js/config.js"></script>
	<script type="text/javascript" src="./../../js/mobile-detect.min.js"></script>
	<script type="text/javascript" src="./../../js/common.js"></script>
	<link rel="stylesheet" href="./../../css/common.css" type="text/css" charset="utf-8" />
</head>
<style>
	#bcid {
		width: 100vw;
		height: 90vh;
	}
</style>

<body>
	<div id="bcid"></div>
</body>
<script type="text/javascript">
	// 扩展API加载完毕后调用onPlusReady回调函数 
	document.addEventListener("plusready", onPlusReady, false);
	// 扩展API加载完毕，现在可以正常调用扩展API
	function onPlusReady() {
		plus.nativeUI.showWaiting("请稍等");
		setTimeout(function(){
			scan = new plus.barcode.Barcode('bcid', [plus.barcode.QR, plus.barcode.CODE39, plus.barcode.CODE128]);
			scan.onmarked = onmarked;
			scan.start();
			plus.nativeUI.closeWaiting();
		}, 1000)
	}
	var scan = null;

	function onmarked(type, result) {
		var text = '未知: ';
		switch (type) {
			case plus.barcode.QR:
				text = 'QR: ';
				break;
			case plus.barcode.CODE39:
				text = 'CODE39: ';
				break;
			case plus.barcode.CODE128:
				text = 'CODE128: ';
				break;
		}
		console.log(text + result);
		scan.cancel();
		scan.close();
	}
</script>

</html>
